home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
dragfo
/
dragform.frm
< prev
next >
Wrap
Text File
|
1995-05-08
|
3KB
|
88 lines
VERSION 2.00
Begin Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Dragging Forms And TextBoxes Demo"
ClientHeight = 3120
ClientLeft = 1320
ClientTop = 1905
ClientWidth = 4575
Height = 3525
Left = 1260
LinkMode = 1 'Source
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 4575
Top = 1560
Width = 4695
Begin TextBox Text1
Height = 1820
Left = 1440
MultiLine = -1 'True
TabIndex = 0
Text = "Text1"
Top = 840
Width = 1455
End
Begin Label Label1
Caption = "To drag the textbox hold down the control key and press the left mouse button."
Enabled = 0 'False
Height = 500
Left = 480
TabIndex = 1
Top = 120
Width = 3735
End
End
Sub Form_DragDrop (Source As Control, X As Single, Y As Single)
Call GetCursorPos(CurPos)
Call ScreenToClient(Form1.hWnd, CurPos)
NewPosX% = CurPos.X - MyPosX%
NewPosY% = CurPos.Y - MyPosY%
Call MoveWindow(TBhWnd, NewPosX%, NewPosY%, TextBoxRect.Right - TextBoxRect.Left, TextBoxRect.Bottom - TextBoxRect.Top, -1)
Text1.Dragmode = 0
Text1.Refresh
End Sub
Sub Form_Load ()
Show
Text1.SetFocus
TBhWnd = GetFocus()
Call GetWindowRect(TBhWnd, TextBoxRect)
End Sub
Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
Call GetCursorPos(CurPos)
Call ScreenToClient(Form1.hWnd, CurPos)
MyPosX% = CurPos.X
MyPosY% = CurPos.Y
End Sub
Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = Left_Button And Shift = 0 Then
Call GetCursorPos(CurPos)
NewPosX% = CurPos.X - MyPosX%
NewPosY% = CurPos.Y - MyPosY%
Call SetWindowPos(Form1.hWnd, 0, NewPosX%, NewPosY%, 0&, 0&, SWP_NOSIZE)
End If
End Sub
Sub Text1_DragDrop (Source As Control, X As Single, Y As Single)
Form_DragDrop Source, X, Y
End Sub
Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)
If Shift = 2 Then
Call GetCursorPos(CurPos)
Call ScreenToClient(TBhWnd, CurPos)
MyPosX% = CurPos.X
MyPosY% = CurPos.Y
Text1.Dragmode = 1
End If
End Sub
Sub Text1_KeyUp (KeyCode As Integer, Shift As Integer)
Text1.Dragmode = 0
End Sub